package com.john.cloud.consumer;

import com.john.cloud.consumer.remote.HelloRemote;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: JohnCoding
 * @Description: hello
 * @date: 2020/5/6 10:39
 */
@RestController
@RefreshScope // 使用该注解的类，会在接到SpringCloud配置中心配置刷新的时候，自动将新的配置更新到该类对应的字段中。
public class HelloController {

    @Autowired
    private HelloRemote helloRemote;


    @Value("${neo.hello}")
    private String hello;


    @GetMapping("cloud")
    public String hello(@RequestParam String name) {
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return helloRemote.hello(name);
    }


    @GetMapping("hello")
    public String from(){
        return this.hello;
    }

}
